<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    .farther{
        width:300px;
        height:300px;
        background-color:pink;
        margin:200px auto;
        display:flex;
        justify-content:center;
        align-items:center;
    }
    .son{
        width:100px;
        height:100px;
        background-color:red;
        text-align:center;
        line-height:100px;
        color:white;
    }
</style>
<body>
    <div class="farther">
        <div class="son">son</div>
    </div>
<script>
    var fa = document.querySelector('.farther');
    var son = document.querySelector('.son');



    //阻止事件冒泡：e.stopPropagation
    son.addEventListener('click',function(e){
        alert('son')
        e.stopPropagation();
        //ie低版本
        e.cancelBubble = true;

    })
    fa.addEventListener('click',function(){
        alert('fa')
    })
    document.addEventListener('click',function(){
        alert('document')
    })
</script>
</body>
</html>